02. Big Picture and Intuition
Big Picture and Developing Your Intuition about Files & I/O
ND079 JPND C2 L02 A02 Big PIcture And Intuition
I/O (Input/Output)
I/O stands for "Input" / "Output". All useful programs have some kind of input and output.
Input is data the program receives from external processes and systems, such as from the local file system or the Internet.
Output is data the program sends to external processes and systems.
Program Memory vs. Persistent Storage
Program Memory
In Java programs and other computer programs, short-term storage happens in the program memory.
- Variables, objects and data structures are stored in the heap and stack. * Memory access is fast.
- Memory is erased when the program is done running.
Persistent Storage
If we want to store data for longer periods of time, we have to use long-term storage, also known as persistent storage.
- Files, stored on disk, are one of the most common forms of persistent storage. Your PC, laptop, and phone all have their own file systems that can store different kinds of files.
- Files stick around, or persist, after the program is done executing, so can also be read by humans or other programs.
- Persistent storage access is usually much slower than memory access.
- Databases are another common form of persistent storage.
SOLUTION:
If the program restarts, the data in memory will be cleared.SOLUTION:
- The file will be there when the program stops running.
- Other programs will be able to read the file.
- Files can store more data than can fit in program memory.